package com.cait.cait.service.impl;

import com.cait.cait.dao.MemberCategoryDao;
import com.cait.cait.dao.MemberDao;
import com.cait.cait.dao.UserDao;
import com.cait.cait.entity.Member;
import com.cait.cait.entity.MemberCategory;
import com.cait.cait.entity.User;
import com.cait.cait.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Jirath
 * @date 2020/2/12
 * @description:
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    MemberDao memberDao;
    @Autowired
    MemberCategoryDao memberCategoryDao;
    @Autowired
    UserDao userDao;

    @Override
    public boolean addMember(Member member) {
        memberDao.addMember(member);
        memberCategoryDao.addRecord(new MemberCategory(member.getMemberId(),0));
        return false;
    }

    @Override
    public Integer getIdentityById(int memberId) {
        Integer memberCategory=memberCategoryDao.getCategory(memberId);
        if(memberCategory==null){
            return -1;
        }
        return memberCategory;
    }

    @Override
    public User getInfoByAccount(String account) {
        return userDao.getPasByUsername(account);
    }
}
